if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[MapInfoEdSponsorCodes]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[MapInfoEdSponsorCodes]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO



/***************************************************************************
* Name:			MapInfoEdSponsorCodes
* Purpose:		Updates the InfoEdSponsorCode column of the AdmSponsor table
*
***************************************************************************/
CREATE PROCEDURE dbo.MapInfoEdSponsorCodes
AS
BEGIN

	SET NOCOUNT ON

--	Update AdmSponsor Set InfoEdSponCode = Stg.Spon_Code
--		From Stg_IE_Sponsors Stg
--		where Stg.nSponsorId = AdmSponsor.RexSponsorId
--
--	-- Match on Name.
--	update AdmSponsor set InfoEdSponCode = Sub.Spon_Code
--		from (select Stg.Spon_Code, S.Id as AdmSponsorId from Stg_IE_Sponsors Stg
--		inner join AdmSponsor S on Stg.sName = S.[Name]
--		Where S.InfoEdSponCode is null) Sub
--		where Sub.AdmSponsorId = AdmSponsor.Id
		
	SET NOCOUNT OFF

END


GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO